﻿using ConfExpert.Forms.Base;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Extensions;
using DevExpress.XtraEditors.Repository;

using DevTeamIT;

namespace ConfExpert.Forms.IT
{
    public partial class AracTakipListesi : XForm
    {
        public AracTakipListesi()
        {
            InitializeComponent();
        }


       
        private void AracListesi_Load(object sender, EventArgs e)
        {

            gvAracListesi.Init("GetAracTakipListesi",Session.SirketId, chkBostaKalanAraclar.Checked);
            gvAracListesi.OptionsView.NewItemRowPosition = DevExpress.XtraGrid.Views.Grid.NewItemRowPosition.Bottom;
           
            RepositoryItemComboBox riDurum = new RepositoryItemComboBox();
            riDurum.Items.AddRange(new object[] { "Aktif", "Pasif", "İptal" });
            riDurum.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor;
            gvAracListesi.Columns["Durum"].ColumnEdit = riDurum;

            RepositoryItemComboBox riTSS = new RepositoryItemComboBox();
            riTSS.Items.AddRange(new object[] { "VAR", "YOK" });
            riTSS.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor;
            gvAracListesi.Columns["TSS"].ColumnEdit = riTSS;

            RepositoryItemComboBox riRenk = new RepositoryItemComboBox();
            riRenk.Items.AddRange(new object[] { "BEYAZ", "GRİ","Ş.BEYAZ","P.GRİ","SİYAH","AÇIK GRİ"});
            riRenk.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor;
            gvAracListesi.Columns["Renk"].ColumnEdit = riRenk;

            RepositoryItemComboBox riSure = new RepositoryItemComboBox();
            riSure.Items.AddRange(new object[] { "35", "36", "24" });
            riSure.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor;
            gvAracListesi.Columns["Sure"].ColumnEdit = riSure;

            gvAracListesi.MakeColumnInvisible("InsertedOn");
            gvAracListesi.AddSummary("YillikKm");
            gvAracListesi.BestFitColumns();

            //ds.IT_Arac.Columns["BitTarihi"].Expression = "BasTarihi+Sure";

            this.FormClosing += AracTakipListesi_FormClosing;
            btnKaydet.ItemClick += btnKaydet_ItemClick;
            chkBostaKalanAraclar.CheckedChanged += chkBostaKalanAraclar_CheckedChanged;
        }

        void AracTakipListesi_FormClosing(object sender, FormClosingEventArgs e)
        {
            DialogResult dr = MessageBox.Show("Değişiklikleri kaydetmemiş olabilirsiniz; çıkmak istediğinize emin misiniz?", "Uyarı", MessageBoxButtons.YesNo);

            if (dr == DialogResult.No)
                e.Cancel = true;
            else
                e.Cancel = false;
        }

        void chkBostaKalanAraclar_CheckedChanged(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            gvAracListesi.VeriyiGuncelle("GetAracTakipListesi", Session.SirketId,chkBostaKalanAraclar.Checked);
            gvAracListesi.BestFitColumns();
        }

        void btnKaydet_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            gvAracListesi.EndEdit();
            gvAracListesi.Update("","IT_Arac");
            gvAracListesi.VeriyiGuncelle("GetAracTakipListesi", Session.SirketId, chkBostaKalanAraclar.Checked);
            gvAracListesi.BestFitColumns();

        }

       
    }
}
